import http from './http'

//获取今日新闻信息 & 轮播图信息
export const queryNewsLatest = ()=> http.get('/api/news_latest')

//获取往日新闻信息
export const queryNews_before = (time)=>{
    return http.get('/api/news_before',{
        params:{ time }
    })
}

//获取新闻详情信息
export const queryNewsInfo = (id)=>{
    return http.get('/api/news_info',{
        params:{ id }
    })
}

//获取新闻详情信息(即点赞、收藏)
export const queryStoryExtra = (id)=>{
    return http.get('/api/story_extra',{
        params:{ id }
    })
}
//发送验证码
export const sendPhoneCode = (phone)=>{
    return http.post('/api/phone_code',{
        phone
    })
}
//登录、注册
export const login = (phone,code)=>{
    return http.post('/api/login',{
        phone,
        code
    })
}
//获取登录者信息
export const queryUserInfo = ()=>{
    return http.get('/api/user_info')
}
//收藏新闻
export const store = (newsId) =>{
    return http.post('/api/store',{
        newsId
    })
}
//移除收藏
export const storeRemove = (id) =>{ //id:即为收藏ID
    return http.post('/api/store_remove',{
        params:{ id }
    })
}
//获取收藏列表
export const storeList = () => http.get('/api/store_list')

//图片上传(要求multipart/form-data格式)
export const upload = (file)=>{
    const fm = new FormData()
    fm.append('file',file)
    return http.post('/api/upload',fm)
}

//修改个人信息
export const userUpdate = (username,pic)=>{
    return http.post('/api/user_update',{
        username,
        pic
    })
}